package zlog

import (
    "encoding/json"
    "strconv"
)

type Field struct {
    Key string
    Val string
}

func Bool(k string, v bool) Field {
    return Field{Key: k, Val: strconv.FormatBool(v)}
}

func String(k string, v string) Field {
    return Field{Key: k, Val: v}
}

func Int8(k string, v int8) Field {
    return Field{Key: k, Val: strconv.FormatInt(int64(v), 10)}
}

func Int(k string, v int) Field {
    return Field{Key: k, Val: strconv.Itoa(v)}
}

func Int16(k string, v int16) Field {
    return Field{Key: k, Val: strconv.FormatInt(int64(v), 10)}
}

func Int32(k string, v int32) Field {
    return Field{Key: k, Val: strconv.FormatInt(int64(v), 10)}
}

func Int64(k string, v int64) Field {
    return Field{Key: k, Val: strconv.FormatInt(int64(v), 10)}
}

func Uint8(k string, v uint8) Field {
    return Field{Key: k, Val: strconv.FormatUint(uint64(v), 10)}
}

func Uint(k string, v uint) Field {
    return Field{Key: k, Val: strconv.FormatUint(uint64(v), 10)}
}

func Uint16(k string, v uint16) Field {
    return Field{Key: k, Val: strconv.FormatUint(uint64(v), 10)}
}

func Uint32(k string, v uint32) Field {
    return Field{Key: k, Val: strconv.FormatUint(uint64(v), 10)}
}

func Uint64(k string, v uint64) Field {
    return Field{Key: k, Val: strconv.FormatUint(uint64(v), 10)}
}

func Float32(k string, v float32) Field {
    return Field{Key: k, Val: strconv.FormatFloat(float64(v), 'f', -1, 32)}
}
func Float64(k string, v float64) Field {
    return Field{Key: k, Val: strconv.FormatFloat(v, 'f', -1, 64)}
}

func Slice(k string, v interface{}) Field {
    s, _ := json.Marshal(v)
    return Field{Key: k, Val: string(s)}
}

func Map(k string, v interface{}) Field {
    s, _ := json.Marshal(v)
    return Field{Key: k, Val: string(s)}
}

func Struct(k string, v interface{}) Field {
    s, _ := json.Marshal(v)
    return Field{Key: k, Val: string(s)}
}

func Interface(k string, v interface{}) Field {
    s, _ := json.Marshal(v)
    return Field{Key: k, Val: string(s)}
}
